import 'dart:ffi';

import 'package:flutter/material.dart';

// 自定义输入框组件
class CustomTextField extends StatelessWidget {
  final TextEditingController controller;
  final String hintText;
  final FormFieldValidator<String>? validator;
  final bool obscureText;

  const CustomTextField({
    super.key,
    required this.controller,
    required this.hintText,
    required this.obscureText,
    this.validator,
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 260,
      child: TextFormField(
        style: TextStyle(color: Colors.white),
        controller: controller,
        cursorColor: Colors.white,
        obscureText: obscureText,
        decoration: InputDecoration(
          // labelText: hintText,
          labelStyle: const TextStyle(color: Colors.white),
          errorStyle: const TextStyle(color: Colors.black38) ,
          hintText: hintText,
          hintStyle: const TextStyle(color: Colors.white),
          enabledBorder: OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(60)),
            borderSide: BorderSide(color: Colors.white, width: 0.7),
          ),
          focusedBorder: OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(60)),
            borderSide: BorderSide(color: Colors.white, width: 0.7),
          ),
          errorBorder: OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(60)),
            borderSide: BorderSide(color: Colors.white70, width: 0.7),
          ),
          focusedErrorBorder: OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(60)),
            borderSide: BorderSide(color: Colors.white70, width: 0.7),
          ),
        ),
        validator: validator,
      ),
    );
  }
}
